﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
using System.Drawing.Printing;
using QuanLyHocPhi.BLL;
namespace QuanLyHocPhi.GUI.TacNghiep
{
    public partial class FormInBangThongKeTheoLop : FormBase
    {
        public LocalReport LocalReport { get { return rv.LocalReport; } }

        public FormInBangThongKeTheoLop()
        {
            InitializeComponent();
        }

        public void LoadReportData(
            List<ThongKeLop> lstThongKe,
            string tenLop,
            string namHoc,
            string tongNo,
            bool laHocPhi)
        {
            var pageSettings = new PageSettings();
            pageSettings.Margins.Top = 30;
            pageSettings.Margins.Bottom = 30;
            pageSettings.Margins.Left = 20;
            pageSettings.Margins.Right = 20;
            pageSettings.Landscape = true;
            pageSettings.PaperSize = new PaperSize("A4", 827, 1169);
            rv.SetPageSettings(pageSettings);
            string ktt = "";
            var thongTin = BizNguoiSuDung.ThongTinDangKy();
            if (thongTin != null)
            {
                ktt = thongTin[0];
            }
            var lstParam = new List<ReportParameter>(){
                new ReportParameter("prTieuDeLop", string.Format("DANH SÁCH SINH VIÊN LỚP {0} CÒN NỢ {1}",tenLop,laHocPhi?"HỌC PHÍ":"LỆ PHÍ")),
                new ReportParameter("prTieuDeThoiGian", string.Format("NĂM HỌC {0} (Tính đến ngày: {1:dd/MM/yyyy})", namHoc, DateTime.Now)),
                new ReportParameter("prTongTienNo", tongNo),
                new ReportParameter("prThoiGianLapBieu", string.Format("Huế, ngày {0} tháng {1} năm {2}", DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year)),
                new ReportParameter("prNguoiLap", Program.NguoiSuDung.HoTen),
                new ReportParameter("prTruongPhong", ktt)
            };
            rv.LocalReport.SetParameters(lstParam);
            ThongKeLopBindingSource.DataSource = lstThongKe;
            rv.RefreshReport();
            rv.SetDisplayMode(DisplayMode.PrintLayout);
            rv.ZoomMode = ZoomMode.Percent;
            rv.ZoomPercent = 100;
            //rv.PrinterSettings.PrinterName = PrintUtil.GetDefaultPrinter();
            this.ShowDialog();
        }

        private void FormInBangChamDiemQTHT_Load(object sender, EventArgs e)
        {
            this.rv.RefreshReport();
        }
    }
}
